package com.shuaigequtan.payment.controller;

import com.shuaigequtan.entity.payment.Payment;
import com.shuaigequtan.payment.service.PaymentService;
import com.shuaigequtan.result.MsgResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/payment")
public class PayMentCtrol {
    @Autowired
    private PaymentService paymentService;

    @Value("${server.port}")
    private String port;

    @GetMapping("/getPayment/{id}")
    public MsgResponseBody getPayment(@PathVariable("id") Long id) {
        Payment payment = paymentService.getById(id);
        String a = "查询"+port+"成功";
        String code ="200";
        return new MsgResponseBody().setMsg(a).setResultCode(code).setData(payment);
    }

    @GetMapping("/addPayment")
    public MsgResponseBody addPayment() {
        Payment payment = new Payment().setSerial("1234567");
        paymentService.insert(payment);
        String a = "添加成功";
        String code ="200";
        return new MsgResponseBody().setMsg(a).setResultCode(code).setData(payment);
    }
}
